<?php
session_start();
if(!isset($_SESSION['login']) || $_SESSION['id_droit'] != 1) header('location:../vue/index.php');
?>
    <!DOCTYPE html>
    <!--
    To change this license header, choose License Headers in Project Properties.
    To change this template file, choose Tools | Templates
    and open the template in the editor
    -->
    <html>
        <head>
            <meta charset="UTF-8">
            <title></title>
        </head>
		<style type="text/css">
		body{
                min-width:800px;
                width:auto!important;
                width:800px;
                height:5000px;
                background-image:url(../img/sharp_edge.png);
                background-repeat:repeat;
				<!--background-attachment:fixed;-->
            }
			
		td{
			color:white;
		}
		
		th{
			color:white;
		}
		
		td select{
			color:black;
		}
		
		td input{
			color:black;
		}
		
		
		</style>
        <body>
            <?php
            include 'navBar.php';
            include 'Include.php';
            include_once '../model/model_sql.php';
            $modelSQL = new SQLBlog();
            $listeUser = $modelSQL->AfficherUtilisateurs();
            echo "<form method='POST' action='../controleur/modif_droit.php' style=\"margin:0 5% 0 5%;\">
            <table class='table'\">
            <th>login</th><th>Nom</th><th>Prenom</th><th>date de naissance</th><th>date inscription</th><th>droit</th>
            ";
            $i = 0;
            foreach ($listeUser as $var) {

                echo "
            <tr>
            <td>" . $var['login'] . "</td>
            <td>" . $var['nom'] . "</td>
            <td>" . $var['prenom'] . "</td>
            <td>" . $var['dateDeNaissance'] . "</td>
            <td>" . $var['dateInscription'] . "</td>
            <td><select name='select" . $i . "'><option value= '1' style=\"color:black;\"";
                if ($var['id_droit'] == 1) {
                    echo "selected ";
                }
                echo ">Administrateur</option><option value='2'";
                if ($var['id_droit'] == 2) {
                    echo "selected ";
                }
                echo ">Visiteur</option> </select>"
                . "<input type='hidden' name='idUser" . $i . "' value='" . $var['id']
                . "'></td></tr>";
                $i++;
            }
            echo "<tr><td colspan='6'><input type='submit'></td></tr></table></form>";
            ?>
        </body>
    </html>
